package thread;

import java.util.HashMap;
import java.util.Scanner;

//单例模式(饿汉模式)，只能实例一个，把构造方法设置为私有，且自身线程安全，因为只有读操作
class Singleton{
    private static Singleton instence = new Singleton();
    private Singleton(){}
    public static Singleton getInstance(){
        return instence;
    }
}
public class Demo9 { 
    public static void main(String[] args) {
        Singleton singleton = Singleton.getInstance();
    }
}
